from pydantic import BaseModel, Field
from typing import List, Optional
from datetime import datetime

class CurveData(BaseModel):
    x_value: float
    y_value: float

class AsphaltSampleBase(BaseModel):
    sampleId: str = Field(..., alias="sample_id", description="样本编号")
    kyqd: float = Field(..., alias="compression_strength", description="抗压强度")
    kyhz: float = Field(..., alias="compression_load", description="抗压荷载")
    cruve: List[str] = Field(..., alias="curve_data", description="曲线数据")

    class Config:
        populate_by_name = True
        allow_population_by_field_name = True

class AsphaltSampleCreate(AsphaltSampleBase):
    pass

class AsphaltSampleResponse(AsphaltSampleBase):
    id: str
    test_id: str
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
        populate_by_name = True
        allow_population_by_field_name = True

class AsphaltTestBase(BaseModel):
    equNum: str = Field(..., alias="equipment_number", description="设备编号")
    precativeNum: str = Field(..., alias="precative_number", description="预制编号")
    trialDate: str = Field(..., alias="trial_date", description="试验日期")

    class Config:
        populate_by_name = True
        allow_population_by_field_name = True

class AsphaltTestCreate(AsphaltTestBase):
    dataList: List[AsphaltSampleCreate] = Field(..., alias="samples", description="样本数据列表")

class AsphaltTestResponse(AsphaltTestBase):
    id: str
    dataList: List[AsphaltSampleResponse] = Field(..., alias="samples", description="样本数据列表")
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True
        populate_by_name = True
        allow_population_by_field_name = True 